/*
 * =====================================================================================
 *
 *       Filename:  cl_logger.hxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  04/12/2011 09:32:10 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Chen Ken (Ken), zlchen.ken@gmail.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#ifndef _CL_LOGGER_HXX_
#define _CL_LOGGER_HXX_

#include <memory>

namespace neo
{

class CLLock;
class CLThread;
class CLLoggerBaseImpl;

class CLLogger
{
public:
  enum CLLogLevel
  {
    LOG_DEBUG,
    LOG_TRACE,
    LOG_INFO,
    LOG_WARNING,
    LOG_CRITICAL,
    LOG_ERROR,
    LOG_FATAL,
    NUM_LOG_LEVELS
  };

public:
  explicit CLLogger(const std::string& filename, bool asyncMode = false);
  ~CLLogger();
	void log(const std::string& facility, 
           const CLLogLevel level, 
           const char* pszFormat, ...);

private:
  CLLogger(const CLLogger&);
  CLLogger& operator=(const CLLogger&);

private:
  std::unique_ptr<CLLoggerBaseImpl> m_logger;
};

extern CLLogger logger__;
#define CLLOG_D(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_DEBUG, fmt, ##args) 

#define CLLOG_T(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_TRACE, fmt, ##args) 

#define CLLOG_I(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_INFO, fmt, ##args) 

#define CLLOG_W(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_WARNING, fmt, ##args) 

#define CLLOG_C(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_CRITICAL, fmt, ##args) 

#define CLLOG_E(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_ERROR, fmt, ##args) 

#define CLLOG_F(fac, fmt, args...) \
	logger__.log(fac, CLLogger::LOG_FATAL, fmt, ##args) 

} // neo

#endif //_CL_LOGGER_HXX_

